package com.zl.tby.vo;

import com.mysql.cj.util.StringUtils;
import com.zl.tby.model.TbyAnimalPlant;
import lombok.Data;
import org.noear.solon.validation.annotation.Length;
import org.noear.solon.validation.annotation.NotBlank;

import java.math.BigDecimal;

/**
 * 动植物管理表单bean
 * @author sunjiaxing
 * @version 1.0
 * @since 2024/8/7 23:33
 */
@Data
public class TbyAnimalPlantForm {
    /**主键id*/
    private Long id;
    /**中文名*/
    @NotBlank(message = "中文名不能为空")
    @Length(max = 20, message = "中文名最大长度为20")
    private String chName;
    /**中文拼音*/
    @Length(max = 50, message = "中文拼音最大长度为50")
    private String chPinyin;
    /**学名*/
    @Length(max = 50, message = "学名最大长度为50")
    private String scientificName;
    /**分类级别 界*/
    private BigDecimal wzBoundary;
    /**分类级别 门*/
    private BigDecimal wzPhylum;
    /**分类级别 纲*/
    private BigDecimal wzCorrect;
    /**分类级别 目*/
    private BigDecimal wzCatalogue;
    /**分类级别 科*/
    private BigDecimal wzSection;
    /**分类级别 属*/
    private BigDecimal wzGenus;
    /**分类级别 种*/
    private BigDecimal wzSpecies;
    /**国家保护等级*/
    @NotBlank(message = "国家保护等级不能为空")
    private String protectionLevel;
    /**是否旗舰物种*/
    @NotBlank(message = "是否旗舰物种不能为空")
    private String isSpecies;
    /**旗舰物种顺序*/
    private String flagshipSpeciesSeq;
    /**物种分级ids*/
    private String typeLevelIds;
    /**物种分类*/
    private Long typeLevel;
    /**简介*/
    @Length(max = 600, message = "简介最大长度为600")
    private String remark;
    /**物种头像*/
    private String files;
    /**经纬度*/
    private String latitudeLongitude;
    /**图层地址*/
    private String layerAddress;
    /**gis上显示得图片路径*/
    private String gisImage;
    /**gis图片在地图上定位得经度*/
    private String gisImageLongitude;
    /**gis图片在地图上定位得纬度*/
    private String gisImageLatitude;
    /**上级分类集合*/
    private String parentIds;
    /**级别集合名称*/
    private String levelNames;
    /**物种分类*/
    private String typeLevelValue;

    private String code;
    /**物种分级集合*/
    private String typeLevels;
    private String cites;
    private String iucn;
    /**生态学*/
    private String ecology;
    /**是否为图例*/
    private Integer legend;
    /**缩略图地址*/
    private String thumbnail;
    /**冠名物种*/
    private Integer sponsorship;
    /**中国珍惜濒危真菌*/
    private Integer isCherish;

    public TbyAnimalPlant createEntity() {
        TbyAnimalPlant entity = new TbyAnimalPlant();
        entity.setId(this.getId());
        entity.setChName(this.getChName());
        entity.setChPinyin(this.getChPinyin());
        entity.setScientificName(this.getScientificName());
        entity.setWzBoundary(this.getWzBoundary());
        entity.setWzCorrect(this.getWzCorrect());
        entity.setWzCatalogue(this.getWzCatalogue());
        entity.setWzGenus(this.getWzGenus());
        entity.setWzSection(this.getWzSection());
        entity.setWzPhylum(this.getWzPhylum());
        entity.setWzSpecies(this.getWzSpecies());
        entity.setProtectionLevel(this.getProtectionLevel());
        entity.setIsSpecies(this.getIsSpecies());
        entity.setFlagshipSpeciesSeq(this.getFlagshipSpeciesSeq());
        entity.setTypeLevel(this.getTypeLevel());
        entity.setFiles(this.getFiles());
        entity.setRemark(this.getRemark());
        entity.setLatitudeLongitude(this.getLatitudeLongitude());
        entity.setLayerAddress(this.getLayerAddress());
        entity.setGisImage(this.getGisImage());
        entity.setGisImageLongitude(this.getGisImageLongitude());
        entity.setGisImageLatitude(this.getGisImageLatitude());
        entity.setLevelNames(this.getLevelNames());
        entity.setTypeLevelIds(this.getTypeLevelIds());
        entity.setTypeLevelValue(this.getTypeLevelValue());
        entity.setTypeLevels(this.getTypeLevels());
        entity.setIucn(this.getIucn());
        entity.setCites(this.getCites());
        entity.setLegend(this.getLegend());
        entity.setEcology(this.getEcology());
        entity.setSponsorship(this.getSponsorship());
        entity.setIsCherish(this.getIsCherish());
//        if(!StringUtils.isNullOrEmpty(this.getParentIds())){
//            //把当前级别id加上
//            this.setParentIds(this.getParentIds()+","+this.getCode());
//            String[] arr = this.getParentIds().split(",");
//            if(arr.length>1){
//                entity.setWzBoundary(arr[1]);
//            }
//            if(arr.length>2){
//                entity.setWzPhylum(arr[2]);
//            }
//            if(arr.length>3){
//                entity.setWzCorrect(arr[3]);
//            }
//            if(arr.length>4){
//                entity.setWzCatalogue(arr[4]);
//            }
//            if(arr.length>5){
//                entity.setWzSection(arr[5]);
//            }
//            if(arr.length>6){
//                entity.setWzGenus(arr[6]);
//            }
//            if(arr.length>7){
//                entity.setWzSpecies(arr[7]);
//            }
//        }
        return entity;
    }

    public void updateEntity(TbyAnimalPlant entity) {
        entity.setChName(this.getChName());
        entity.setChPinyin(this.getChPinyin());
        entity.setScientificName(this.getScientificName());
        entity.setWzBoundary(this.getWzBoundary());
        entity.setWzCorrect(this.getWzCorrect());
        entity.setWzCatalogue(this.getWzCatalogue());
        entity.setWzGenus(this.getWzGenus());
        entity.setWzSection(this.getWzSection());
        entity.setWzPhylum(this.getWzPhylum());
        entity.setWzSpecies(this.getWzSpecies());
        entity.setProtectionLevel(this.getProtectionLevel());
        entity.setIsSpecies(this.getIsSpecies());
        entity.setFlagshipSpeciesSeq(this.getFlagshipSpeciesSeq());
        entity.setTypeLevel(this.getTypeLevel());
        entity.setFiles(this.getFiles());
        entity.setRemark(this.getRemark());
        entity.setLatitudeLongitude(this.getLatitudeLongitude());
        entity.setLayerAddress(this.getLayerAddress());
        entity.setGisImageLatitude(this.getGisImageLatitude());
        entity.setGisImageLongitude(this.getGisImageLongitude());
        entity.setGisImage(this.getGisImage());
        entity.setLevelNames(this.getLevelNames());
        entity.setTypeLevelIds(this.getTypeLevelIds());
        entity.setTypeLevelValue(this.getTypeLevelValue());
        entity.setTypeLevels(this.getTypeLevels());
        entity.setIucn(this.getIucn());
        entity.setCites(this.getCites());
        entity.setLegend(this.getLegend());
        entity.setEcology(this.getEcology());
        entity.setSponsorship(this.getSponsorship());
        entity.setIsCherish(this.getIsCherish());
//        if(!StringUtils.isNullOrEmpty(this.getParentIds())){
//            //把当前级别id加上
//            this.setParentIds(this.getParentIds()+","+this.getCode());
//            String[] arr = this.getParentIds().split(",");
//            if(arr.length>1){
//                entity.setWzBoundary(arr[1]);
//            }
//            if(arr.length>2){
//                entity.setWzPhylum(arr[2]);
//            }
//            if(arr.length>3){
//                entity.setWzCorrect(arr[3]);
//            }
//            if(arr.length>4){
//                entity.setWzCatalogue(arr[4]);
//            }
//            if(arr.length>5){
//                entity.setWzSection(arr[5]);
//            }
//            if(arr.length>6){
//                entity.setWzGenus(arr[6]);
//            }
//            if(arr.length>7){
//                entity.setWzSpecies(arr[7]);
//            }
//        }
    }


}
